var prefix = ctx + "manage/userDailyActivity";
var prefixAdRecord = ctx + "manage/adRecord";

$(function () {
    var options = {
        url: prefix + "/list",
        queryParams: queryParams,
        columns: [
            {
                field: 'usId',
                title: '用户id'
            },
            {
                field: 'usNickname',
                title: '用户ID'
            },
            {
                field: 'udaIp',
                title: '登录IP',
                formatter: function (value, row, index) {
                    return '<a href="#" onclick="getIp(\'' + row.udaIp + '\')">' + value + '</a>';
                }
            },
            {
                field: 'udaAddress',
                title: '地址'
            },
            {
                field: 'udaLat',
                title: '经度'
            },
            {
                field: 'udaLng',
                title: '纬度'
            },
            {
                field: 'loginTime',
                title: '登录时间'
            },
            {
                title: '广告记录',
                align: 'center',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a style="margin-left: 10px" class="btn btn-info btn-xs" href="#" onclick="queryAdRecord(\'' + row.usId + '\')"><i></i>详细</a>');
                    return actions.join('');
                }
            },
            {
                title: '设备环境',
                align: 'center',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a style="margin-left: 10px" class="btn btn-info btn-xs" href="#" onclick="queryDetail(\'' + row.usId + '\')"><i></i>详细</a>');
                    return actions.join('');
                }
            }
        ]
    };
    $.ryTable.init(options);
});

/*奖励记录-搜索*/
function search() {
    $('.bootstrap-table').bootstrapTable('refresh', queryParams);
}

function queryParams(params) {
    var createTime = $('#createTime').val();
    return {
        // 传递参数查询参数
        pageSize: params.limit,
        pageNum: params.offset / params.limit + 1,
        arChannel: $("#arChannel option:selected").val(),
        usId: $("#usId").val(),
        nickname: $("#usNickname").val(),
        udaIp: $("#udaIp").val(),
        startTime: createTime === '' ? '' : startCreatTime,
        endTime: createTime === '' ? '' : endTime
    };
}

function queryDetail(id) {
    var url = prefix + "/my/" + id;
    layer_showAuto("风控日志详细", url);
}

function queryAdRecord(id) {
    var url = prefixAdRecord + '/' + id;
    layer_showAuto("广告记录详细", url);
}

function getIp(id) {
    var url = prefix + "/ip/?ip=" + id;
    layer_showAuto("登录IP详细", url);
}

